<template>
  <div class="hbb-cent">
    <div style="background-color: #A9AFBB;">
      <div class="hbb-cent-hedar">
        <ul>
          <li @click="get_list(1)" :class="{active1:avitvs1==1}">最新上架</li>
          <li @click="get_list(item.id)" :class="{active:avitvs==(index+2)}" v-for="(item , index) in list" :key="index">{{item.name}}</li>
        </ul>
      </div>
    </div>

    <div v-if="blindBoxlist" class="hbb-list">
        <ul>
          <li v-for="( item ,index) in blindBoxlist" :key="index"  @click="getOpenBlind(item.id)">
            <div>
              <div class="hbb-list-anmite"></div>
              <div class="hbb-list-box"><img :src="item.backgroundImage" ></div>
              <div class="hbb-list-item"><img :src="item.image" ></div>
            </div>
            <div>
              <div>{{item.name}}</div>
              <div><div><img src="../assets/money-icon.png" ></div><p>{{item.price}}</p></div>
            </div>
          </li>
        </ul>
         <div v-if="listkey" style="font-size: 14px;color: #999999;">暂无内容</div>
    </div>
    <div v-else><img style="margin-top: 50px;width: 96px;height: 96px;" src="../assets/loding.gif" ></div>
  </div>
</template>

<script>
export default {
 data () {
    return {
      avitvs:'',
      avitvs1:1,
      list:[],
      blindBoxlist:[],
      listkey : false,
    }
  },
  methods: {
      // addClass($event){
      //   $event.currentTarget.className = 'activ';
      //  },
      // calerClass($event){
      //  $event.currentTarget.className = '';
      // }
      get_list(e){
          if(e>1){
            this.avitvs=e;
            this.avitvs1 = null
          }else{
            this.avitvs1 = 1;
            this.avitvs=null;
          }
          this.get_lists(e)
      },
      getOpenBlind(id){
        this.$router.push({
                  path: `/openblind/${id}`,
            })
      },
      get_blindBoxType(){
        this.$api.get('/api/home/blindBoxType', null, r => {
                this.list = r.data
               })
      },
      get_lists(e){
        this.listkey = false
        this.$api.get('/api/home/blindBox',
        {
          typeId:e
        }
        , r => {
                this.blindBoxlist = r.data.content
                if(r.data.content.length==0){
                  this.listkey = true;
                }
               })
      }
  },
  mounted() {
    this.get_blindBoxType();
    this.get_list(1);
  }
}
</script>

<style scoped>
  .hbb-list-anmite{
    background-image:url(../assets/hbb-list-bg.png);
    background-repeat: no-repeat;
    background-position: 30px 30px;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    z-index: 1;
  }
  .hbb-list ul li:hover .hbb-list-anmite{
     background-image:url(../assets/hbb-list-bgac.png);
     background-position: 5px 5px;
     transform: rotate(90deg);
     transition:all .5s ease-out;
  }
  .hbb-list ul li:hover .hbb-list-item{
   /* background-position: 5px 5px;
     margin-top: -40px; */
    top: 40%;
    left: 50%;
    transition: 0.5s;
    transform: translate(-50%, 0%) rotate(-5deg);
  }
  .hbb-list-item{
    position: absolute;
    z-index: 9;
    max-width: 140px;
    max-height: 140px;
    width: auto ;
    height: auto;
    top: 50%;
    left: 50%;
    transition:all 0.5s;
    transform: translate(-50%, -50%);
  }
  .hbb-list-item img{
    position: absolute;
    max-width: 140px;
    max-height: 140px;
    width: auto ;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .hbb-list-box{
    position: absolute;
    width: 146px;
    height: 146px;
    top: 50%;
    margin-top: -60px;
    left: 50%;
    margin-left: -70px;
    z-index: 6;
  }
  .hbb-list-box img{
    position: absolute;
    max-width: 146px;
    max-height: 146px;
    width: auto ;
    height: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .hbb-cent-hedar{
    width: 1200px;
    margin: 0 auto;
    background-color: #242C40;
  }
  .hbb-list{
    width: 1200px;
    margin: 0 auto;
    background-color: #141A28;
    padding: 32px 30px;
    box-sizing: border-box;
    min-height: 452px;
  }
  .hbb-list ul{
    display: flex;
    /* justify-content: space-between; */
    flex-wrap: wrap;
    padding-bottom: 30px;
  }
  .hbb-list ul li{
    /* margin-bottom: 50px; */
    margin-right: 6px;
    cursor: pointer;
  }
  .hbb-list ul li:nth-child(4n){
    margin-right: 0px;
  }
  .hbb-list ul li>div:first-child{
    width: 280px;
    height: 280px;
    position: relative;
  }

  .hbb-list ul li>div:last-child{
    margin:0 auto;
    width:260px ;
  }
  .hbb-list ul li>div:last-child>div:first-child{
    width: 162px;
    height: 35px;
    background-image: url(../assets/hbb-btn-bgs.png);
    background-size: 100% 100%;
    margin:  0 auto;
    line-height: 35px;
    color: #FFFFFF;
  }
  .hbb-list ul li:hover>div:last-child>div:first-child{
    background-image: url(../assets/hbb-btn-bg.png);
  }
  .hbb-list ul li>div:last-child>div:last-child{
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px auto;
    font-size: 16px;
    color: #FFA32A;
  }
  .hbb-list ul li>div:last-child>div:last-child p{
    margin-left: 5px;
  }
.hbb-cent{
  width: 100%;
  margin:  0 auto;
  background-color: #12151B;
}
.hbb-cent .hbb-cent-hedar ul{
  display: flex;
}
.hbb-cent .hbb-cent-hedar ul>li{
  width: 221px;
  height: 49px;
  text-align: center;
  line-height: 49px;
  color: #FFFFFF;
  cursor: pointer;
  font-size: 18px;
  position: relative;
  overflow: hidden;
  background-size: 100% 100%;
  background-repeat:no-repeat;
  background-position: -220px 0;
  transition: all .5s;
  background-image: url(../assets/bk-tal2-bgs.png);
}
.hbb-cent .hbb-cent-hedar ul>li:nth-child(1){
  background-image: url(../assets/bk-tal1-bgs.png);
  width: 220px;
  height: 49px;
  background-size: 100% 100%;
  /* color: #000000; */
  position: relative;
  z-index: 9;
}

.hbb-cent .hbb-cent-hedar ul>li:nth-child(2){
  width: 220px;
  height: 49px;
  z-index: 8;
  position: relative;
}
.hbb-cent .hbb-cent-hedar ul>li:nth-child(3){
  z-index: 7;
  position: relative;
}
.hbb-cent .hbb-cent-hedar ul>li:nth-child(4){
  z-index: 6;
  position: relative;
}
.hbb-cent .hbb-cent-hedar ul>li:nth-child(5){
  z-index: 5;
  position: relative;
}
.hbb-cent .hbb-cent-hedar ul>li:not(:nth-child(1)){
   margin-left: -29px;
   position: relative;
}
.hbb-cent .hbb-cent-hedar ul>li::after{
  position: absolute;
  top: -20px;
  right: 19px;
  bottom: -20px;
  content: "";
  width: 40px;
  background-color: #242C40;
  transform: rotate(31deg);
}
.hbb-cent .hbb-cent-hedar ul>li:not(:nth-child(1))::before{
  position: absolute;
  top: -20px;
  left: -19px;
  bottom: -20px;
  content: "";
  width: 40px;
  background-color: #242C40;
  transform: rotate(31deg);
}
.hbb-cent .hbb-cent-hedar ul>li:hover{
  color: #000000;
  background-image: url(../assets/bk-tal1-bgs.png);
  background-size: 100% 100%;
  background-position: 0px 0;
  transition: all .5s;
}
.hbb-cent .hbb-cent-hedar ul>li:hover::after{
  display: none;
}
.hbb-cent .hbb-cent-hedar ul>li:not(:nth-child(1)):hover{
 background-image: url(../assets/bk-tal2-bgs.png);
}
.hbb-cent .hbb-cent-hedar .active{
  background-image: url(../assets/bk-tal2-bgs.png);
  background-size: 100% 100%;
  color: #000000;
  background-position: 0px 0;
}
.hbb-cent .hbb-cent-hedar .active::after{
  display: none;
}
.hbb-cent .hbb-cent-hedar .active1{
 background-image: url(../assets/bk-tal1-bgs.png) ;
  width: 220px;
  height: 49px;
  background-size: 100% 100%;
  color: #000000;
  background-position: 0px 0;
}
.hbb-cent .hbb-cent-hedar .active1::after{
  display: none;
}
</style>
